package com.ruoyi.costumeShop.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.costumeShop.domain.CostumeSize;
import com.ruoyi.costumeShop.service.ICostumeSizeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 尺码管理Controller
 * 
 * @author ruoyi
 * @date 2022-04-05
 */
@RestController
@RequestMapping("/costumeShop/size")
public class CostumeSizeController extends BaseController
{
    @Autowired
    private ICostumeSizeService costumeSizeService;

    /**
     * 查询尺码管理列表
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:size:list')")
    @GetMapping("/list")
    public TableDataInfo list(CostumeSize costumeSize)
    {
        startPage();
        List<CostumeSize> list = costumeSizeService.selectCostumeSizeList(costumeSize);
        return getDataTable(list);
    }

    /**
     * 导出尺码管理列表
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:size:export')")
    @Log(title = "尺码管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CostumeSize costumeSize)
    {
        List<CostumeSize> list = costumeSizeService.selectCostumeSizeList(costumeSize);
        ExcelUtil<CostumeSize> util = new ExcelUtil<CostumeSize>(CostumeSize.class);
        util.exportExcel(response, list, "尺码管理数据");
    }

    /**
     * 获取尺码管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:size:query')")
    @GetMapping(value = "/{sizeId}")
    public AjaxResult getInfo(@PathVariable("sizeId") Long sizeId)
    {
        return AjaxResult.success(costumeSizeService.selectCostumeSizeBySizeId(sizeId));
    }

    /**
     * 新增尺码管理
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:size:add')")
    @Log(title = "尺码管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CostumeSize costumeSize)
    {
        return toAjax(costumeSizeService.insertCostumeSize(costumeSize));
    }

    /**
     * 修改尺码管理
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:size:edit')")
    @Log(title = "尺码管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CostumeSize costumeSize)
    {
        return toAjax(costumeSizeService.updateCostumeSize(costumeSize));
    }

    /**
     * 删除尺码管理
     */
    @PreAuthorize("@ss.hasPermi('costumeShop:size:remove')")
    @Log(title = "尺码管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sizeIds}")
    public AjaxResult remove(@PathVariable Long[] sizeIds)
    {
        return toAjax(costumeSizeService.deleteCostumeSizeBySizeIds(sizeIds));
    }
}
